<template>
	<view>

		<view class="mainpadding">
			<u-swiper :list="list1" height="200" indicator circular @click="lbtclick"></u-swiper>
			<u-sticky bgColor="#fff">
				<!-- <u-navbar title="题目列表" :titleStyle="{fontWeight:'800'}" bgColor="#fff" placeholder>
					<view class="u-nav-slot" slot="left">
						<view class="flexleft">
							<view class="xiaohei bold" style="font-size: 28rpx;">{{city_text}}</view>
							<u-icon name="map" size="16" color="#333"></u-icon>
						</view>
					</view>
				</u-navbar> -->
				<view style="background-color: #ffffff;">
					<!-- <view class="mainpadding">
						<view class="ffffff flexbetween ssbox">
							<view class="flexleft">
								<u-icon name="search" color="#999" size="20"></u-icon>
								<input type="text" placeholder="请输入搜索内容" class="hei_text main_size bold">
							</view>
							<view class="rightss">搜索</view>
						</view>
					</view> -->
					<!-- <view class="flexbetween" style="padding: 0 30rpx;">
						<view class="flexleft">
							<view class="shijianbtn margin_right1" @click="zshijian">{{startime}}</view>
							<view class="xian margin_right1"></view>
							<view class="shijianbtn" @click="yshijian">{{endtime}}</view>
						</view>
						<view class="submitbtn2 textcenter" @click="chongzhi">重置</view>
					</view> -->
					<view class="">
						<u-tabs :list="tabslist" :scrollable="false" :current='current' @change="tabclick"></u-tabs>
					</view>
				</view>
			</u-sticky>
			<!-- #ifdef APP-PLUS || H5 -->
			<view class="flexcenter" v-if="!list.data.length && !isloding&&city_id">
			<!-- #endif -->
				<!-- #ifdef MP-WEIXIN -->
				<view class="flexcenter" v-if="!list.data.length && !isloding">
				<!-- #endif -->
					<view class="placeholderimage" style="margin-top: 100rpx;"></view>
				</view>
				<!-- <view class="mainpadding_top ffffff radius" v-if="(item.type==2 && item.tsurveyLink=='')?false:true" v-for="item in list.data" :key="item.id" @click="dati(item)"> -->
				<template v-if="tabsId==1">
					<view class="mainpadding_top ffffff radius" v-for="item in list.data" :key="item.id"
						@click="datijx(item)">
						<view class="flexleft">
							<image :src="item.image_text" class="listleftimg radius margin_right" mode=""></image>
							<view>
								<view class="flexbetween pdl" style="width: 100%;">
									<!-- <view class="hei_text bold titletext xiankuan" style="word-wrap: break-word;width: 286rpx;">请另行在小程序开发工具的控制台查看</view> -->
									<view class="bold titletext xiankuan" :class="item.is_dt==1?'xiaolv':'hei_text'"
										style="word-wrap: break-word;width: 286rpx;">
										{{item.title}}
									</view>
									<view class="" @click.stop="yjdjshow=true">
										<text class="lan_text bold" style="font-size: 40rpx;">+{{item.score}}</text>
										<text class="xiaohui">/{{item.dj_rate}}%</text>
									</view>
								</view>
								<view class="flexbetween margin_top">
									<view class="hui_text bold main_size time-min-width">Loi:{{item.rec_dtsj}}分钟</view>
									<view class="flexright">
										<!-- #ifdef APP-PLUS -->
										<!-- <view class="listbtnlan flexcenter" @click.stop="sharewx">
										<u-icon name="share" size="16" color="#3478f5"></u-icon>
										<view class="margin_left1">分享</view>
									</view> -->
										<!-- #endif -->
										<!-- #ifdef MP-WEIXIN -->
										<!-- <view class="" @click.stop="zuzhi" v-if="!islogin">
										<view class="listbtnlan flexcenter">
											<u-icon name="share" size="16" color="#3478f5"></u-icon>
											<view class="margin_left1">分享</view>
										</view>
									</view>
									<view class="" @click.stop="zuzhi" v-else>
										<button hover-class="none" open-type="share">
											<view class="listbtnlan flexcenter">
												<u-icon name="share" size="16" color="#3478f5"></u-icon>
												<view class="margin_left1">分享</view>
											</view>
										</button>
									</view> -->
										<!-- #endif -->
										<!-- <view class="listbtnlan flexcenter margin_left">
										<u-icon name="file-text" size="16" color="#3478f5"></u-icon>
										<view class="margin_left1">答题</view>
									</view> -->
									</view>
								</view>
							</view>
						</view>

					</view>
				</template>
			</view>
			<template v-if="tabsId==2">
				<view class="flexbetween flex_wrap mainpadding">
					<view class="" :class="index==0 || index==1?'':'margin_top'" v-for="(item,index) in list.data"
						:key="item.id" @click="dati(item)" style="width: 45%;height: 120rpx;position: relative;">
						<image :src="item.image_text" style="width: 100%;height: 100%;border-radius: 15rpx;" mode="">
						</image>
						<view class="flexleft posijiao" @click.stop="yjdjshow=true">
							<view class="xiaobai bold" style="font-size: 20rpx;">冻结比例:{{item.dj_rate}}%</view>
							<u-icon name="question-circle" size="16" color="#fff"></u-icon>
						</view>
					</view>
				</view>
			</template>
			<!-- #ifdef APP-PLUS || H5 -->
			<template v-if="!isloding&&city_id">
			<!-- #endif -->
				<!-- #ifdef MP-WEIXIN -->
				<template v-if="!isloding">
				<!-- #endif -->
					<view class="xiaohui flexcenter" style="padding-bottom: 30rpx;" v-if="list.last_page > page"
						@click="onReachBottomt()">获取更多题目</view>
					<view class="xiaohui flexcenter" v-if="list.last_page <= page" style="padding-bottom: 30rpx;">已经拉到底了
					</view>
				</template>
				<!-- #ifdef APP-PLUS || H5 -->
				<template v-if="isloding&&city_id">
				<!-- #endif -->
					<!-- #ifdef MP-WEIXIN -->
					<template v-if="isloding">
					<!-- #endif -->
						<view class="xiaohui flexcenter" style="padding-bottom: 30rpx;">加载中...</view>
					</template>
					<!-- #ifdef APP-PLUS || H5 -->
					<template v-if="!city_id">
						<view class="xiaolan flexcenter" @click="getLocation()"
							style="font-size: 28rpx;padding-bottom: 30rpx;margin-top: 100rpx;">获取题目</view>
					</template>
					<!-- #endif -->
					<u-modal :show="datishow" title="答题须知" showCancelButton :confirmText="confirmtext" cancelText="再想想"
						@confirm="xuzhisure(1)" @cancel="datishow=false">
						<view class="slot-content">
							<scroll-view scroll-y="true" style="height: 600rpx;">
								<u-parse :content="dtxzContent"></u-parse>
							</scroll-view>
						</view>
					</u-modal>
					<u-modal :show="yjdjshow" title="佣金冻结比例" confirmText="我已知晓" @confirm="yjdjshow=false">
						<view class="slot-content">
							<scroll-view scroll-y="true" style="height: 600rpx;">
								<u-parse :content="yjdjContent"></u-parse>
							</scroll-view>
						</view>
					</u-modal>
					<u-modal :show="xcxshow" title="答题" showCancelButton @cancel="xcxshow=false" cancelText="关闭"
						confirmText="保存二维码" @touchmove.prevent @confirm="saveqrcode">
						<view class="slot-content" style="width: 600rpx;">
							<view class="flexcenter" v-if="xcxshow">
								<uqrcode ref="uqrcode" canvas-id="qrcode" @click="ewmfn" v-bind:value="qrcodeurl"
									:options="{ margin: 10}" size="150">
								</uqrcode>
							</view>
							<view class="mainpadding">
								<view class="textcenter">
									<text class="main_size lan_text bold" @click="xuzhisure(2)">点击此处</text>
									<text class="main_size hei_text">复制链接至手机浏览器，参与答题赢取奖励。
										或扫描二维码下载最新版趣调研APP获取最佳使用体验。</text>
								</view>
							</view>
						</view>
					</u-modal>
					<u-modal :show="smrzShow" title="您还未完成实名认证暂时无法使用此功能!" showCancelButton confirmText="点击去认证"
						@confirm="jumpurl('/pages/mine/shimingrz','')" @cancel="smrzShow=false"></u-modal>
					<u-modal :show="jzdyToastShow" title="新用户达到1000积分可解锁精选调查功能!" showCancelButton cancel-text="我已知晓"
						confirmText="不再提醒" @confirm="jzdyToastShowClick" @cancel="jzdyToastShow = false"></u-modal>
					<!-- #ifdef APP-PLUS || H5 -->
					<zy-update theme="blue" :appstoreflag="true" :autocheckupdate="true" :updateurl="updateurl">
					</zy-update>
					<yk-authpup ref="authpup" type="top" @changeAuth="changeAuth"
						:permissionID="permissionID"></yk-authpup>
					<!-- #endif -->
					<u-datetime-picker :show="zshow" @confirm="zconfirm" v-model="value1" mode="date"
						@cancel="zshow= false" :maxDate="Number(new Date())"></u-datetime-picker>
					<u-datetime-picker :show="yshow" @confirm="yconfirm" v-model="value2" mode="date" @cancel="yshow= false"
						:minDate="minDate" :maxDate="Number(new Date())"></u-datetime-picker>
		</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	const QQMapWX = require('@/common/qqmap-wx-jssdk.min.js');
	import ZyUpdate from '@/components/zy-upgrade/zy-upgrade.vue'
	import ykAuthpup from "@/components/yk-authpup/yk-authpup";
	// 实例化API核心类
	const qqmapsdk = new QQMapWX({
		key: '3BVBZ-W5K6J-4H6FX-DG2NS-F2LSZ-EOBYE' // 必填
	});
	export default {
		// #ifdef APP-PLUS  || H5
		components: {
			ZyUpdate,
			ykAuthpup
		},
		// #endif
		data() {
			return {
				updateurl: 'https://interestingdy.overseassurvey.com/api/index/getDownloadUrl',
				tabslist: [{
					id: "1",
					name: "精选问卷",
					disabled: false
				}, {
					id: "2",
					name: "全球调研联盟",
					disabled: false
				}],
				current: 0,
				tabsId: 1,
				list1: [],
				bannerList: [],
				datishow: false,
				dtxzContent: "",
				yjdjshow: false,
				yjdjContent: "",
				lat: "",
				lng: "",
				city_text: "",
				city_id: "",
				smrzShow: false, //实名认证弹出框
				code: "",
				page: 1,
				limit: 12,
				list: {
					data: []
				},
				currentmsg: {},
				userInfo: {},
				shareAll: {},
				islogin: false,
				confirmtext: "我已知晓",
				timer: null,
				xcxshow: false,
				qrcodeurl: "http://baidu.com", //app下载地址
				isloding: true,
				jzdyToastShow: false,
				permissionID: '',
				isload: false,
				minDate: "",
				//开始时间
				zshow: false,
				value1: Number(new Date()),
				//结束
				yshow: false,
				value2: Number(new Date()),
				startime: "开始时间",
				endtime: "结束时间",
			}
		},
		watch: {
			current(val) {
				console.log('是否进了监听');
				this.list.data = [];
			}
		},
		async onLoad(options) {
			if (options.code) {
				uni.setStorageSync("yqrcode", options.code)
			}
			let isloginOnload = httpRequest.checkIsLogin()
			if (!isloginOnload) {
				await this.getUserInfo();
				// #ifdef MP-WEIXIN
				this.getLocation()
				// #endif
			}
			this.getbanner()
			this.getdata()
		},
		async onShow() {
			this.islogin = httpRequest.checkIsLogin()
			if (this.islogin) {
				await this.getinfo()
				await this.getUserInfo();
				// #ifdef MP-WEIXIN 
				this.getLocation()
				// #endif
			} else {
				// 没有登录的时候要干掉这个。只能选择全球调研联盟
				// this.tabslist[0].disabled = true
				// this.tabsId = 2;
				// this.current = 1
				// if (!uni.getStorageSync('isJzdyToast')) this.jzdyToastShow = true;''
				// #ifdef MP-WEIXIN  
				this.getLocation()
				// #endif
			}
		},
		onHide() {
			// this.jzdyToastShow = false;
		},
		onPullDownRefresh() {
			this.init()
		},
		onShareAppMessage() {
			let _this = this
			return {
				title: "趣调研",
				path: "pages/index/index?code=" + uni.getStorageSync("invite_code"),
			}
		},
		onShareTimeline: function() {
			return {
				title: "趣调研",
				path: "pages/index/index?code=" + uni.getStorageSync("invite_code"),
			}
		},
		methods: {
			// 开始时间
			zconfirm(e) {
				console.log(e)
				this.selecttime = ""
				this.minDate = e.value
				this.startime = this.date(e.value)
				this.init()
				this.zshow = false
			},
			zshijian() {
				this.zshow = true
			},
			yshijian() {
				if (this.minDate == "") {
					httpRequest.toast("请选择开始时间")
					return
				}
				this.yshow = true
			},
			chongzhi(){
				this.startime = "开始时间"
				this.endtime = "结束时间"
				this.init()
			},
			//结束时间
			yconfirm(e) {
				console.log(e)
				this.selecttime = ""
				this.endtime = this.date(e.value)
				this.init()
				this.yshow = false
			},
			datijx(item) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/appLogin"
					})
					return false
				}
				if(item.type==2){
					this.dati(item)
					return false
				}
				uni.navigateTo({
					url: "/pages/index/diaoyanxq?id=" + item.id
				})
				
			},
			date(timer) {
				var date = new Date(timer); //当前时间
				var year = date.getFullYear() //返回指定日期的年份
				var month = repair(date.getMonth() + 1); //月
				var day = repair(date.getDate()); //日
				var curTime = year + "-" + month + "-" + day
			
				function repair(i) {
					if (i >= 0 && i <= 9) {
						return "0" + i;
					} else {
						return i;
					}
				}
				return curTime
			},
			jzdyToastShowClick() {
				uni.setStorageSync('isJzdyToast', 1);
				this.jzdyToastShow = false;
			},
			// 获取用户信息
			getUserInfo() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					// if (res.data.total_score < 1000) {
					// 	this.tabslist[0].disabled = true
					// 	if (!this.isload) {
					// 		this.tabsId = 2;
					// 		this.current = 1
					// 	}

					// 	// if (!uni.getStorageSync('isJzdyToast')) this.jzdyToastShow = true;
					// } else {
					// 	if (!this.isload) {
					// 		this.tabsId = 1;
					// 		this.current = 0;
					// 	}
					// 	this.tabslist[0].disabled = false
					// }
					this.isload = true
				})
			},
			ewmfn() {
				this.$refs.uqrcode.toTempFilePath({
					success: res => {

						var i = [res.tempFilePath]; //获取当前页面的轮播图数据
						//uniapp预览轮播图
						uni.previewImage({
							current: 0, //预览图片的下标
							urls: i //预览图片的地址，必须要数组形式，如果不是数组形式就转换成数组形式就可以
						})
					}
				});
			},
			zuzhi() {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/appLogin"
					})
					return false
				}
			},
			sharewx() {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/appLogin"
					})
					return false
				}
				let that = this
				uni.share({
					provider: "weixin",
					scene: "WXSceneSession",
					type: 0,
					href: that.shareAll.share_url + '?code=' + uni.getStorageSync("invite_code"),
					title: that.shareAll.share_title,
					summary: that.shareAll.share_des,
					imageUrl: that.shareAll.share_logo,
					success: function(res) {
						console.log("success:" + JSON.stringify(res), "分享成功");
					},
					fail: function(err) {
						console.log("fail:" + JSON.stringify(err), "分享失败");
					}
				});
			},
			getdata() {
				let _this = this;
				httpRequest.request('/api/index/getConfigInfo', 'GET', {}).then(res => {
					if (res.code == 1) {
						this.qrcodeurl = res.data.share_url
						this.shareAll = res.data
						this.yjdjContent = res.data.yjdj_des
					}
				})
			},
			getinfo() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			init(isPage, page) {
				let _this = this;
				// if (!this.city_id) {
				// 	setTimeout(() => {
				// 		uni.stopPullDownRefresh()
				// 	}, 300)
				// 	return false
				// }
				//yangxu

				// uni.showLoading({
				// 	'mask':true,
				// 	'title':'题目加载中'
				// })
				this.isloding = true
				const testData = {
					page: page || 1,
					limit: _this.limit,
					city_id: this.city_id,
					type: this.tabsId,
					start_time: this.startime == "开始时间" ? '' : this.startime,
					end_time: this.endtime == "结束时间" ? '' : this.endtime,
				}
				// console.log(testData, 'testData..............');
				httpRequest.request('/api/user/tmIndex', 'GET', {
					page: page || 1,
					limit: _this.limit,
					city_id: this.city_id,
					type: this.tabsId
				}, false, false, true).then(res => {
					uni.stopPullDownRefresh()
					// uni.hideLoading();
					this.isloding = false
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = res.data
							_this.list.data = resList.data;
						}

						console.log(_this.list.data, this.tabsId, '_this.list.data');
					}

				}).catch(err => {
					// uni.hideLoading();
					this.isloding = false
					// httpRequest.toast(err.msg);
				})
			},
			onReachBottomt() {

				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			// #ifdef MP-WEIXIN 
			getLocation() {
				let _this = this
				uni.getLocation({
					type: 'gcj02',
					geocode: true,
					success: function(res) {
						console.log(res, "获取位置成功");
						//逆地址解析  坐标转地址信息
						_this.lat = res.latitude
						_this.lng = res.longitude
						// _this.init()
						qqmapsdk.reverseGeocoder({
							//Object格式
							location: {
								latitude: res.latitude,
								longitude: res.longitude
							},
							success: function(res) { //成功后的回调

								_this.code = res.result.ad_info.phone_area_code
								const mapdata = res.result.address_component;
								_this.city_text = mapdata.city; //省地址
								_this.getCurrCity()

								// _this.currentAddress = res.result.address //详细地址
							},
							fail: function(error) {
								console.log(error, "获取位置失败");
							},
							complete: function(res) {}
						});
					},
					fail(err) {
						console.log(err, "cuowu");
					}
				});
			},
			// #endif
			// #ifdef APP-PLUS 
			changeAuth() {
				//这里是权限通过后执行自己的代码逻辑
				// console.log('权限已授权，可执行自己的代码逻辑了');
				// uni.makePhoneCall({
				//   phoneNumber: this.data.contacts_tel,
				//   fail: (e) => {
				//     console.log(e)
				//   }
				// });

			},
			// 获取当前位置信息
			getLocation() {
				let _this = this
				this.permissionID =
					'ACCESS_FINE_LOCATION'; //这个是对应的权限 ACCESS_FINE_LOCATION 位置权限 / WRITE_EXTERNAL_STORAGE 存储空间/照片权限 / CAMERA相机权限 / CALL_PHONE 拨打电话
				setTimeout(() => {
					this.$refs['authpup'].open();
				}, 500)
				uni.getLocation({
					type: 'gcj02',
					geocode: true, //设置该参数为true可直接获取经纬度及城市信息
					success: function(res) {
						_this.lat = res.latitude
						_this.lng = res.longitude
						_this.city_text = res.address.city
						// _this.code = res.address.cityCode
						_this.getCurrCity()

					},
					fail(err) {
						console.log(err, "定位错误信息")
					}
				});
			},
			// #endif
			getCurrCity() {
				httpRequest.request('/api/index/getCurrCity', 'POST', {
					code: this.city_text
				}, false, false, true).then(res => {
					if (res.code == 1) {
						this.city_id = res.data.id
						this.init()
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			getbanner() {
				httpRequest.request('/api/index/picIndex', 'GET', {}).then(res => {
					res.data.forEach(item => {
						this.list1.push(item.image_text)
					})
					this.bannerList = res.data
				})
			},
			lbtclick(index) {
				if (this.bannerList[index].is_dz == 1) {
					uni.navigateTo({
						url: "/pages/system/bannerdetail?id=" + this.bannerList[index].id
					})
				}
			},
			dati(item) {

				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/appLogin"
					})
					return false
				}
				// #ifdef MP-WEIXIN 
				this.dtxzContent = item.content
				if (item.type == 2) {
					uni.showLoading({
						title: '加载中'
					})
					httpRequest.request('/api/user/tmtoluna', 'GET', {
						type: item.type,
						QuotaID: item.QuotaID,
						id: item.id
					}).then(res => {
						if (res.code == 1) {
							uni.hideLoading();
							this.currentmsg = item
							this.currentmsg.tsurveyLink = res.data.tsurveyLink;
							this.currentmsg.errmsg = res.data.errmsg;
							this.xcxshow = true
						}
					})
				} else {
					this.currentmsg = item
					this.xcxshow = true
				}
				// #endif
				// #ifdef APP-PLUS || H5
				// if (this.userInfo.is_smrz == 1) {
				// 	httpRequest.toast("未完成实名认证，请先完成实名认证")
				// 	return false
				// }
				if (this.userInfo.is_complete == 1) {
					httpRequest.toast("个人信息基本资料未完善，请先完善")
					return false
				}
				// this.confirmtext = "我已知晓(5)"
				// let num = 5
				// this.timer = setInterval(() => {
				// 	num = num - 1
				// 	if(num==0){
				// 		clearInterval(this.timer)
				// 		this.confirmtext = "我已知晓"
				// 	}else{
				// 		this.confirmtext = "我已知晓(" + num + ")"
				// 	}
				// }, 1000)
				this.dtxzContent = item.content
				if (item.type == 2) {
					uni.showLoading({
						title: '加载中'
					})
					httpRequest.request('/api/user/tmtoluna', 'GET', {
						type: item.type,
						QuotaID: item.QuotaID,
						id: item.id
					}).then(res => {
						if (res.code == 1) {
							uni.hideLoading();
							this.currentmsg = item
							this.currentmsg.tsurveyLink = res.data.tsurveyLink;
							this.currentmsg.errmsg = res.data.errmsg;
							// this.datishow = true
							this.xuzhisure(1)
						}
					})
				} else {
					this.currentmsg = item
					// this.datishow = true
					this.xuzhisure(1)
				}
				// #endif
				console.log(88888888888, this.currentmsg);
			},
			xuzhisure(val) {
				// if (val == 1) {
				// 	if (this.confirmtext != "我已知晓") {
				// 		return false
				// 	}
				// }
				// 在此处写前置事件，2024-03-08
				this.datishow = false
				this.xcxshow = false
				let url2 = this.currentmsg.tsurveyLink
				console.log(this.currentmsg.type, 'this.currentmsg.type')
				if (this.currentmsg.type == 2 && url2 == "") {
					httpRequest.toast(this.currentmsg.errmsg)
					return false
				}
				if (url2 == "") {
					return false
				}

				uni.showLoading({
					title: '题目加载中...'
				})
				let that = this;
				if (this.tabsId == 1) {
					uni.request({
						url: 'https://www.overseassurvey.com/surveyfe/login',
						method: 'POST',
						data: {
							username: uni.getStorageSync('username'),
							password: uni.getStorageSync('password')
						},
						success(res) {
							// console.log(res,'后台登录接口');
							const test = {
								tsurveyProviderId: that.currentmsg.tsurveyProviderId,
								tsurveyId: that.currentmsg.tSurveyId,
								tsurveyCpa: that.currentmsg.tSurveyCpa,
								tsurveyLoi: that.currentmsg.tSurveyLoi,
								trewardValue: that.currentmsg.tRewardValue,
								surveyLink: that.currentmsg.tSurveyLink,
								ttype: that.currentmsg.tSurveyType,
							}
							console.log(that.currentmsg, 'currentmsg.......');
							console.log(test, 'test...');
							// console.log(res.data.data.token,'token....');
							uni.request({
								url: 'https://www.overseassurvey.com/surveyfe/surveyRecord/addSurveyOrder',
								method: 'POST',
								header: {
									token: res.data.data.token
								},
								data: {
									tsurveyProviderId: that.currentmsg.tsurveyProviderId,
									tsurveyId: that.currentmsg.tSurveyId,
									tsurveyCpa: that.currentmsg.tSurveyCpa,
									tsurveyLoi: that.currentmsg.tSurveyLoi,
									trewardValue: that.currentmsg.tRewardValue,
									surveyLink: that.currentmsg.tSurveyLink,
									ttype: that.currentmsg.tSurveyType,
								},
								success(rez) {
									console.log(rez, '后台记录接口');
									uni.hideLoading();
									if (that.currentmsg.type == 1) {
										let url = that.currentmsg.tsurveyLink.substring(0, that.currentmsg
												.tsurveyLink.length - 5) + uni
											.getStorageSync("user_id")
										let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
										url2 = url.replace(reg1, "");
									}
									if (that.currentmsg.type == 2 || that.currentmsg.type == 3) {
										let url = that.currentmsg.tsurveyLink
										let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
										url2 = url.replace(reg1, "");
									}
									if (that.currentmsg.type == 3) {
										let url = that.currentmsg.tsurveyLink + "&userid=" + that
											.currentmsg.id +
											'ac96a9df980b4605a4e2301713c74c51' + uni
											.getStorageSync("user_id");

										let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
										url2 = url.replace(reg1, "");
										that.addTmRecord(that.currentmsg.id);
									}
									if (that.currentmsg.type == 4) {

										let url = that.currentmsg.tsurveyLink + "?api_key=" + that
											.currentmsg.api_key + "&user_id=app" + uni
											.getStorageSync("user_id") + "&transaction_id=" + uni
											.getStorageSync("user_id")

										// let url = that.currentmsg.tsurveyLink + "?apiKey=" + that.currentmsg.api_key + '&gender=Male' + '&age=43' + '&subId2=pc' + "&user_id=" + uni.getStorageSync("user_id") + "&userId=" + uni.getStorageSync("user_id")
										let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
										url2 = url.replace(reg1, "");
									}
									if (that.currentmsg.type == 4 && that.currentmsg.tsurveyId ==
										"wannads") {
										// let url = that.currentmsg.tsurveyLink + "?apiKey=" + that
										// 	.currentmsg.api_key + '&gender=Male' + '&age=43' +
										// 	'&subId2=pc' + "&user_id=" + uni.getStorageSync("user_id") +
										// 	"&userId=" + uni.getStorageSync("user_id")
										let url = that.currentmsg.tsurveyLink + '&gender=Male' +
											'&age=43' +
											'&subId2=pc' + "&user_id=" + uni.getStorageSync("user_id") +
											"&userId=" + uni.getStorageSync("user_id")

										let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
										url2 = url.replace(reg1, "");
									}
									// if (that.currentmsg.type == 4&&tsurveyId="theoremreach") {
									// 	console.log(that.currentmsg,'that.currentmsg')
									// 	let url = that.currentmsg.tsurveyLink + "&userId=" + uni
									// 		.getStorageSync("user_id") + "&user_id=" + uni
									// 		.getStorageSync("user_id")
									// 	let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
									// 	url2 = url.replace(reg1, "");
									// }


									if (that.currentmsg.type == 5) {
										let url = that.currentmsg.tsurveyLink + "&subid_2=" + "app" +
											"&ext_user_id=" + uni
											.getStorageSync("user_id") + "&ip_user=" + that.currentmsg
											.userIp + "&user_id=app" + uni
											.getStorageSync("user_id")
										let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
										url2 = url.replace(reg1, "");
										console.log(that.currentmsg, "我=5我是链接");

										console.log(that.currentmsg, "我=5我是链接");
										if (val == 1) {
											let data = {
												url2,
												item: that.currentmsg
											}
											console.log(data, 'datadatadatadatadata')
											uni.navigateTo({
												url: "/pages/index/cpx?data=" + encodeURIComponent(
													JSON.stringify(data))
											})
											return false;
										}
									}
									if (that.currentmsg.type == 6) {
										let str = that.currentmsg.tsurveyLink
										let resps = (that.getCaption(str)).substring(6)
										let obj = JSON.parse(resps)
										let url1 = that.getqianCaption(str)
										that.$set(obj, "ip", that.currentmsg.userIp)
										that.$set(obj, "device_id", uni.getStorageSync("user_id")
											.toString())

										// console.log(url1,"我是链接6666");
										// console.log(obj,"我是链接777")
										// return false
										let url = url1 + "&json=" + JSON.stringify(obj)
										let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
										url2 = url.replace(reg1, "");
										console.log(url2, "我=6我是链接");
									}
									console.log(url2, 'url2')
									// return false
									let data = {
										url2
									}

									if (val == 1) {
										let timeId = null

										plus.runtime.openURL(url2)
										// #ifdef APP-PLUS

										// #endif

										return false
										// 之前逻辑需要判断（下面是之前逻辑），现在改成所有都是跳转浏览器了
										// if (that.currentmsg.type == 2 || that.currentmsg.type == 3) {
										// 	plus.runtime.openURL(url2)
										// 	return false
										// }
										// uni.navigateTo({
										// 	url: "/pages/webview/webview?msg=" + encodeURIComponent(JSON.stringify(data))
										// })
									} else {
										that.copy(data.url2)
									}

								}
							})
						},
						fail(err) {
							uni.hideLoading();
							console.log(err, '接口抛出错误');
						}
					})
				} else {
					uni.hideLoading();
					if (that.currentmsg.type == 1) {
						let url = that.currentmsg.tsurveyLink.substring(0, that.currentmsg.tsurveyLink.length - 5) + uni
							.getStorageSync("user_id")
						let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
						url2 = url.replace(reg1, "");
					}
					if (that.currentmsg.type == 2 || that.currentmsg.type == 3) {
						let url = that.currentmsg.tsurveyLink
						let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
						url2 = url.replace(reg1, "");
					}
					if (that.currentmsg.type == 3) {
						let url = that.currentmsg.tsurveyLink + "&userid=" + that.currentmsg.id +
							'ac96a9df980b4605a4e2301713c74c51' + uni
							.getStorageSync("user_id");

						let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
						url2 = url.replace(reg1, "");
						that.addTmRecord(that.currentmsg.id);
					}
					if (that.currentmsg.type == 4) {

						let url = that.currentmsg.tsurveyLink + "?api_key=" + that.currentmsg.api_key + "&user_id=app" +
							uni
							.getStorageSync("user_id") + "&transaction_id=" + uni
							.getStorageSync("user_id")
						// let url = that.currentmsg.tsurveyLink + "?apiKey=" + that.currentmsg.api_key + '&gender=Male' + '&age=43' + '&subId2=pc' + "&user_id=" + uni.getStorageSync("user_id") + "&userId=" + uni.getStorageSync("user_id")
						let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
						url2 = url.replace(reg1, "");
					}
					if (that.currentmsg.type == 4 && that.currentmsg.tsurveyId == "wannads") {
						// let url = that.currentmsg.tsurveyLink + "?apiKey=" + that.currentmsg.api_key + '&gender=Male' +
						// 	'&age=43' + '&subId2=pc' + "&user_id=" + uni.getStorageSync("user_id") + "&userId=" + uni
						// 	.getStorageSync("user_id")
						let url = that.currentmsg.tsurveyLink + '&gender=Male' +
							'&age=43' + '&subId2=pc' + "&user_id=" + uni.getStorageSync("user_id") + "&userId=" + uni
							.getStorageSync("user_id")
						let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
						url2 = url.replace(reg1, "");
					}
					// if (that.currentmsg.type == 4&&tsurveyId="theoremreach") {
					// 	console.log(that.currentmsg,'that.currentmsg')
					// 	let url = that.currentmsg.tsurveyLink + "&userId=" + uni
					// 		.getStorageSync("user_id") + "&user_id=" + uni
					// 		.getStorageSync("user_id")
					// 	let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
					// 	url2 = url.replace(reg1, "");
					// }


					if (that.currentmsg.type == 5) {
						let url = that.currentmsg.tsurveyLink + "&subid_2=" + "app" + "&ext_user_id=" + uni
							.getStorageSync("user_id") + "&ip_user=" + that.currentmsg.userIp + "&user_id=app" + uni
							.getStorageSync("user_id")
						let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
						url2 = url.replace(reg1, "");
						console.log(that.currentmsg, "我=5我是链接");

						console.log(that.currentmsg, "我=5我是链接");
						if (val == 1) {
							let data = {
								url2,
								item: that.currentmsg
							}
							console.log(data, 'datadatadatadatadata')
							uni.navigateTo({
								url: "/pages/index/cpx?data=" + encodeURIComponent(JSON.stringify(data))
							})
							return false;
						}
					}
					if (that.currentmsg.type == 6) {
						let str = that.currentmsg.tsurveyLink
						let resps = (that.getCaption(str)).substring(6)
						let obj = JSON.parse(resps)
						let url1 = that.getqianCaption(str)
						that.$set(obj, "ip", that.currentmsg.userIp)
						that.$set(obj, "device_id", uni.getStorageSync("user_id").toString())

						// console.log(url1,"我是链接6666");
						// console.log(obj,"我是链接777")
						// return false
						let url = url1 + "&json=" + JSON.stringify(obj)
						let reg1 = new RegExp("amp;", "g"); // 加'g'，删除字符串里所有的"amp"
						url2 = url.replace(reg1, "");
						console.log(url2, "我=6我是链接");
					}
					console.log(url2, 'url2')
					// return false
					let data = {
						url2
					}

					if (val == 1) {
						let timeId = null

						plus.runtime.openURL(url2)
						// #ifdef APP-PLUS

						// #endif

						return false
						// 之前逻辑需要判断（下面是之前逻辑），现在改成所有都是跳转浏览器了
						// if (that.currentmsg.type == 2 || that.currentmsg.type == 3) {
						// 	plus.runtime.openURL(url2)
						// 	return false
						// }
						// uni.navigateTo({
						// 	url: "/pages/webview/webview?msg=" + encodeURIComponent(JSON.stringify(data))
						// })
					} else {
						that.copy(data.url2)
					}
				}

			},
			unsettm(tm_id) {
				var list = this.list;
				list.data.forEach((item, index) => {
					if (item['id'] == tm_id) {
						this.list.data.splice(index, 1)
					}
				})
			},

			addTmRecord(tm_id) {
				httpRequest.request('/api/user/addTmRecord', 'GET', {
					tm_id: tm_id
				}).then(res => {
					if (res.code == 1) {
						this.unsettm(this.currentmsg.id);
					}
				})
			},

			copy(value) {

				uni.setClipboardData({
					data: value, //要被复制的内容
					success: () => {
						//复制成功的回调函数
						httpRequest.toast("复制成功")
					}
				});
			},
			saveqrcode() {
				this.xcxshow = false
				this.$refs.uqrcode.save({
					success: () => {
						uni.showToast({
							icon: 'success',
							title: '保存成功'
						});
					}
				});
			},
			getqianCaption(obj) {
				const index = obj.lastIndexOf("&json")
				const res = obj.substring(0, index)
				return res
			},
			getCaption(obj) {
				const index = obj.lastIndexOf("&json")
				const res = obj.substring(index, obj.length)
				return res
			},

			tabclick(item) {
				this.tabsId = item.id;
				console.log(this.tabsId, "999");
				this.list.data = [];
				// #ifdef APP-PLUS
				if (this.city_id == '') {
					this.getLocation();
					return false;
				}
				// #endif

				this.init()
			},

			jumpurl(url, id) {
				uni.navigateTo({
					url: url + id
				})
			},
		}
	}
</script>

<style>
	/* .xian {
		width: 22rpx;
		height: 0rpx;
		background-color: #999999;
		border: 1rpx solid #999999;
	} */
	.posijiao {
		position: absolute;
		top: -15rpx;
		right: -10rpx;
		background-color: #3478f5;

		padding: 10rpx 15rpx;
		border-radius: 50rpx;
	}

	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.time-min-width {
		min-width: 200rpx;
	}

	/* page {
		background-color: #333;
	} */
	.shijianbtn {
		padding: 20rpx 30rpx;
		background: #fafafa;
		border-radius: 41rpx;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #999999;
	}
	.submitbtn2{
		background-color: #ff0000;
		border-radius: 50rpx;
		text-align: center;
		color: #fff;
		font-size: 28rpx;
		padding: 10rpx 30rpx;
	}
</style>